
import java.sql.*;

/**
 * Created by yangxianming on 2015-06-18.
 */
public class TestMysql {
    public static void main(String[] args) {
        String url = "jdbc:mysql://10.201.2.13:3306/survey_0305?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull";
        String user = "mq-user";
        String pw = "redhat";
        String field = "SURVEY_TITLE";
        String sql = "SELECT SURVEY_TITLE FROM SURVEY WHERE SURVEY_ID=76020";
        Connection conn = null;
        try {
            conn = DriverManager.getConnection(url, user, pw);
            Statement statement = conn.createStatement();
            ResultSet resultSet = statement.executeQuery(sql);
            System.out.println(resultSet.findColumn(field));
            while (resultSet.next()){
                System.out.printf("%s:%s %n", field, resultSet.getString(1));
                break;
            }


        }catch (SQLException e){
            e.printStackTrace();
        }
    }
}
